/* 创建HTTPS服务器 */


var https = require('https');

var fs = require('fs');

var pk = fs.readFileSync('./privatekey.pem');

var pc = fs.readFileSync('./certificate.pem');

var opts = {
	key: pk,
	cert: pc
};


var server = https.createServer(opts, function(req, res){
	console.log(req.url);

	if(req.url !== './favicon.ico'){
		res.setHeader('Content-Type', 'text/html');
		res.write("你好");
		res.end();
	}
});

server.listen(443, 'localhost');

server.on('listening', function(){
	console.log("server is listening");
	server.close();
});

server.on('close', function(){
	console.log("server is closed");
});